package com.shine.controller.shuihu;

import com.shine.entity.ShuiHu;
import com.shine.service.ShuiHuService;
import com.shine.service.impl.ShuiHuServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/getShuiHus")
public class GetAllShuihuController extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 设置字符集
        // 设置编码
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=utf-8");

        ShuiHuService shuiHuService = new ShuiHuServiceImpl();
        List<ShuiHu> shuiHus = shuiHuService.queryAllShuiHu();

        request.getSession().setAttribute("shuiHus",shuiHus);

        request.getRequestDispatcher("/shuihus.jsp").forward(request,response);
    }
}
